package kr.saeildamil.androidforstudy2.ch22;

import kr.saeildamil.androidforstudy2.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

public class BlurFilter extends Activity {
		
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(new MyView(this));
		}
		
		protected class MyView extends View{

			public MyView(Context context) {
				super(context);
			}
			
			@Override
			protected void onDraw(Canvas canvas) {
				canvas.drawColor(Color.LTGRAY);
				Paint paint = new Paint();
				paint.setAntiAlias(true);
				
				Bitmap cup = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.korandoc);
				
				BlurMaskFilter blur = new BlurMaskFilter(20, BlurMaskFilter.Blur.NORMAL);
				paint.setMaskFilter(blur);
				canvas.drawBitmap(cup, 30, 30, paint);
			}
		}
}
